<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改使用条款')" />
    <th:block th:include="include :: summernote-css"/>
    <th:block th:include="include :: select2-css" />
</head>
<style>
    .submited{
        float: right;
        width: 120px;
        height: 40px;
        background: linear-gradient(#ff0000,#ff1155);
        border: 0;
        border-radius: 5px;
        color: #ffff;
        font-size: 18px;
        margin-right: 17%;
    }
    .control-label{font-size: 18px;font-weight: bold;}
    .spaker{;color: #0d8ddb;}
</style>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-useTerms-edit" th:object="${useTerms}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-2 control-label" >积分转换率：</label>
                <div class="col-sm-4">
                    <select name="exchangeRatio" th:field="*{exchangeRatio}" class="form-control m-b">
                        <option value="0.01">1%</option>
                        <option value="0.02">2%</option>
                        <option value="0.03">3%</option>
                        <option value="0.04">4%</option>
                        <option value="0.05">5%</option>
                        <option value="0.06">6%</option>
                        <option value="0.07">7%</option>
                        <option value="0.08">8%</option>
                        <option value="0.09">9%</option>
                        <option value="0.10">10%</option>
                    </select>

                </div>
                <div class="col-sm-4 ">
                    <span class="help-block m-b-none" ><i class="fa fa-info-circle"></i> <span class="spaker">说明: 公众号端用户进行积分转换为余额时的比例</span></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">积分返还率：</label>
                <div class="col-sm-4">
                    <select name="returnRatio" th:field="*{returnRatio}" class="form-control m-b">
                        <option value="0.10">10%</option>
                        <option value="0.20">20%</option>
                        <option value="0.30">30%</option>
                        <option value="0.40">40%</option>
                        <option value="0.50">50%</option>
                        <option value="0.60">60%</option>
                        <option value="0.70">70%</option>
                        <option value="0.80">80%</option>
                        <option value="0.90">90%</option>
                        <option value="1.00">100%</option>
                    </select>

                </div>
                <div class="col-sm-4 ">
                    <span class="help-block m-b-none" ><i class="fa fa-info-circle"></i> <span class="spaker">说明: 公众号端用户成功支付后获得的积分比例</span></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">归属商家返利比：</label>
                <div class="col-sm-4">
                    <select name="belongRatio" th:field="*{belongRatio}" class="form-control m-b">
                        <option value="0.00">0%</option>
                        <option value="0.05">5%</option>
                        <option value="0.10">10%</option>
                        <option value="0.15">15%</option>
                        <option value="0.20">20%</option>
                        <option value="0.25">25%</option>
                        <option value="0.30">30%</option>
                        <option value="0.35">35%</option>
                        <option value="0.40">40%</option>
                        <option value="0.45">45%</option>
                        <option value="0.50">50%</option>
                    </select>
                </div>
                <div class="col-sm-4 spaker">
                    <span class="help-block m-b-none" ><i class="fa fa-info-circle"></i> <span class="spaker">说明: 公众号端用户支付后其归属商家获得返利比率</span></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">用户额外手续费：</label>
                <div class="col-sm-4">
                    <select name="userAdded" th:field="*{userAdded}" class="form-control m-b">
                        <option value="0.00">0元</option>
                        <option value="1.00">1元</option>
                        <option value="2.00">2元</option>
                        <option value="3.00">3元</option>
                        <option value="4.00">4元</option>
                        <option value="5.00">5元</option>
                        <option value="6.00">6元</option>
                        <option value="7.00">7元</option>
                        <option value="8.00">8元</option>
                        <option value="9.00">9元</option>
                        <option value="10.00">10元</option>
                    </select>
                </div>
                <div class="col-sm-4 ">
                    <span class="help-block m-b-none" ><i class="fa fa-info-circle"></i> <span class="spaker">说明: 公众号端用户提现额外支付的费用</span></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">商家额外手续费：</label>
                <div class="col-sm-4">
                    <select name="shopAdded" th:field="*{shopAdded}" class="form-control m-b">
                        <option value="0.00">0元</option>
                        <option value="1.00">1元</option>
                        <option value="2.00">2元</option>
                        <option value="3.00">3元</option>
                        <option value="4.00">4元</option>
                        <option value="5.00">5元</option>
                        <option value="6.00">6元</option>
                        <option value="7.00">7元</option>
                        <option value="8.00">8元</option>
                        <option value="9.00">9元</option>
                        <option value="10.00">10元</option>
                    </select>
                </div>
                <div class="col-sm-4 " >
                    <span class="help-block m-b-none" ><i class="fa fa-info-circle"></i> <span class="spaker">说明: 公众号端商家提现额外支付的费用</span></span>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-2 control-label">流动金额：</label>
                <div class="col-sm-2">
                    <input type="text" name="terraceMoney" th:field="*{terraceMoney}" class="form-control">
                </div>
                <div class="col-sm-4 ">
                    <span class="help-block m-b-none" ><i class="fa fa-info-circle"></i> 说明: 平台的流动资金,慎重修改</span>
                </div>
            </div>-->
            <div class="form-group">
                <label class="col-sm-2 control-label">商家提现补贴：</label>
                <div class="col-sm-4">
                    <label class="toggle-switch switch-solid">
                        <input type="checkbox" id="status" th:checked="${useTerms.status}=='0'">
                        <input type="text" name="status" hidden>
                        <span></span>
                    </label>
                </div>
                <div class="col-sm-4 ">
                    <span class="help-block m-b-none" ><i class="fa fa-info-circle"></i> <span class="spaker">说明: 公众号端商家进行银行卡提现是否进行补贴</span></span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">使用说明：</label>
                <div class="col-sm-8">
                    <input name="content" th:field="*{content}"  type="text" hidden>
                    <div class="summernote" id="editor"></div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">商家条款：</label>
                <div class="col-sm-8">
                    <input name="advContent" th:field="*{advContent}"  type="text" hidden>
                    <div class="summernote2" id="editor2"></div>
                </div>
            </div>
        </form>
        <button onclick="submitHandler()" class="submited"> 确定</button>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js"/>
    <th:block th:include="include :: select2-js" />
    <script type="text/javascript">
        var prefix = ctx + "useTerms/useTerms";
        $("#form-useTerms-edit").validate({
            focusCleanup: true
        });
        var content = $("input[name='content']").val();
        $('#editor').summernote('code', content);
        $('.summernote').summernote({
            placeholder: '请输入内容',
            height: 192,
            lang: 'zh-CN',
            followingToolbar: false,
            callbacks: {
                onImageUpload: function (files) {
                    sendFile(files[0], this);
                }
            }
        });

        var advContent = $("input[name='advContent']").val();
        $('#editor2').summernote('code', advContent);
        $('.summernote2').summernote({
            placeholder: '请输入内容',
            height: 192,
            lang: 'zh-CN',
            followingToolbar: false,
            callbacks: {
                onImageUpload: function (files) {
                    sendFile(files[0], this);
                }
            }
        });
        // 上传文件
        function sendFile(file, obj) {
            var data = new FormData();
            data.append("file", file);
            $.ajax({
                type: "POST",
                url: ctx + "common/upload",
                data: data,
                cache: false,
                contentType: false,
                processData: false,
                dataType: 'json',
                success: function (result) {
                    if (result.code == web_status.SUCCESS) {
                        $(obj).summernote('editor.insertImage', result.url, result.fileName);
                    } else {
                        $.modal.alertError(result.msg);
                    }
                },
                error: function (error) {
                    $.modal.alertWarning("图片上传失败。");
                }
            });
        }
        function submitHandler() {
            var sHTML = $('.summernote').summernote('code');
            $("input[name='content']").val(sHTML);
            var sHTML2 = $('.summernote2').summernote('code');
            $("input[name='advContent']").val(sHTML2);
            var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
            $("input[name='status']").val(status)
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-useTerms-edit').serialize());
            }
        }
    </script>
</body>
</html>